<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件



/*
 * 把时间戳变成分钟小时或者天
 * */
function timeToFormat($time){


    $w = ['秒钟','分钟','小时','天','月','年'];
    $d = [60,60,24,30,12];

    for ($i=0;$i<=4;$i++){
        $t = floor($time/$d[$i]);
        if ($t < 1 ){
            return $time.$w[$i];
        }else{
            $time = $t;
        }
    }
    
    
    return $time.$w[5];

}
